<template>
	<view>
		<uni-popup ref="dialog">
			<view class="bg-white rounded" style="width: 600rpx;">
				<view style="height: 100rpx;" class="border-bottom border-light-secondary flex align-center justify-center font-weight-bold">
					{{title}}
				</view>
				<view class="flex align-center justify-center p-3">
					<slot ></slot>
				</view>
				<view class="flex border-top border-light-secondary" style="height: 100rpx;">
					<view @tap="cancel" class="flex-1 text-muted flex align-center justify-center">
						{{cancelText}}
					</view>
					<view @tap="confirm" class="flex-1 text-main flex align-center justify-center">
						{{confirmText}}
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '../../components/uni-ui/uni-popup/uni-popup.vue';
	export default {
		components: {
			 uniPopup
		},
		data() {
			return {
				
			};
		},
		props:{
			title:{
				type:String,
				default:'提示'
			},
			cancelText:{
				type:String,
				default:'取消'
			},
			confirmText:{
				type:String,
				default:'确定'
			},
		},
		data(){
			return {
				callback:false
			}
		},
		methods:{
			open(callback=false){
				this.callback=callback
				this.$refs.dialog.open()
			},
			cancel(){
				this.$emit('cancel')
				this.$refs.dialog.close()
			},
			confirm(){
				if(typeof this.callback==='function'){
					this.callback(()=>{
						this.cancel()
					})
				}else{
					this.$emit('confirm')
					this.cancel()
				}
			}
		}
	}
</script>

<style>

</style>
